package com.robot.agent.client;

import com.robot.agent.client.impl.MerchantClientImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * merchant模块跨域调用
 *
 * @author lin
 */
@Component
@FeignClient(value = "robot-merchant", fallback = MerchantClientImpl.class)
public interface MerchantClient {
    /**
     * 店铺列表并分页和条件查询
     *
     * @param searchMap
     * @param page
     * @param size
     * @return
     */
    @PostMapping(value = "store/third/findStores/{page}/{size}", produces = "application/json; charset=utf-8")
    public String thirdFindStores(@RequestBody Map searchMap, @PathVariable int page, @PathVariable int size);

    /**
     * 店铺详情
     *
     * @param id
     * @return
     */
    @GetMapping(value = "store/third/findStoreById/{id}", produces = "application/json; charset=utf-8")
    public String thirdFindStoreById(@PathVariable String id);

    /**
     * 通过phone查询店铺详情
     *
     * @param phone
     * @return
     */
    @GetMapping(value = "store/third/findStoreByPhone/{phone}", produces = "application/json; charset=utf-8")
    public String thirdFindStoreByPhone(@PathVariable String phone);

    /**
     * 通过agentId查询店铺列表
     *
     * @param agentId
     * @param page
     * @param size
     * @return
     */
    @GetMapping(value = "store/third/findStoresByAgentIdOrderByCreatedAtDesc/{agentId}/{page}/{size}", produces = "application/json; charset=utf-8")
    public String thirdFindStoresByAgentIdOrderByCreatedAtDesc(@PathVariable String agentId, @PathVariable int page, @PathVariable int size);

    /**
     * 通过id和agentId查询店铺详情
     *
     * @param id
     * @param agentId
     * @return
     */
    @GetMapping(value = "store/third/findStoreByIdAndAgentId/{id}/{agentId}", produces = "application/json; charset=utf-8")
    public String thirdFindStoreByIdAndAgentId(@PathVariable String id, @PathVariable String agentId);

    /**
     * agent根据agentId查找昨天开张的店铺
     *
     * @param agentId
     * @param page
     * @param size
     * @return
     */
    @GetMapping(value = "store/third/findStoresByAgentIdAndYesterday/{agentId}/{page}/{size}", produces = "application/json; charset=utf-8")
    public String thirdFindStoresByAgentIdAndYesterday(@PathVariable String agentId, @PathVariable int page, @PathVariable int size);

    /**
     * agent根据agentId查找最近7日开张的店铺
     *
     * @param agentId
     * @param page
     * @param size
     * @return
     */
    @GetMapping(value = "store/third/findStoresByAgentIdAndWeek/{agentId}/{page}/{size}", produces = "application/json; charset=utf-8")
    public String thirdFindStoresByAgentIdAndWeek(@PathVariable String agentId, @PathVariable int page, @PathVariable int size);

    /**
     * agent根据agentId查找总开张的店铺
     *
     * @param agentId
     * @param page
     * @param size
     * @return
     */
    @GetMapping(value = "store/third/findStoresByAgentIdAndTotal/{agentId}/{page}/{size}", produces = "application/json; charset=utf-8")
    public String thirdFindStoresByAgentIdAndTotal(@PathVariable String agentId, @PathVariable int page, @PathVariable int size);

    /**
     * 修改店铺
     *
     * @param store
     */
    @PutMapping(value = "store/third/updateStore")
    @Transactional(rollbackFor = Exception.class)
    public void thirdUpdateStore(@RequestBody String store);


    /**
     * 根据id查找行业
     *
     * @param id
     * @return
     */
    @GetMapping(value = "industry/third/findIndustryById/{id}", produces = "application/json;charset=utf-8")
    public String thirdFindIndustryById(@PathVariable String id);
}